<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class BasesModel extends BaseModel
{
    use SoftDeletes;

    protected $fillable   = ['name', 'location', 'address', 'area', 'lat', 'lng', 'master_name', 'phone', 'status', 'province_id', 'city_id', 'district_id'];

    protected $table      = 'base';

    protected $primaryKey = 'base_id';

    public function setPicturesAttribute($pictures)
    {
        if (is_array($pictures)) {
            $this->attributes['pictures'] = json_encode($pictures);
        }
    }

    public function getPicturesAttribute($pictures)
    {
        return json_decode($pictures, true);
    }

    public function setPhoneAttribute($value)
    {
        $this->attributes['phone'] = str_replace('_', '', $value);
    }
}

